<template>
	<view>
		<!--header-->
		<tui-navigation-bar splitLine @init="initNavigation" @change="opcityChange" :scrollTop="scrollTop" title="我的"
			backgroundColor="255,255,255" color="#333">
			<view class="tui-header-box" :style="{paddingTop:top+'px'}">
					我的
			</view>
		</tui-navigation-bar>
		<!--header-->
		<view class="tui-mybg-box">
			<image :src="tui.imghost+'static/home/img/mybg-lei.png'" class="tui-my-bg" mode="widthFix"></image>
			<view class="tui-header-center">
				<image :src="userInfo.avatar?userInfo.avatar:'/static/images/my/mine_def_touxiang_3x.png'"
					class="tui-avatar"  data-page="../userInfo/userInfo"></image>
				<view class="tui-info">
					<view class="tui-nickname" data-page="../userInfo/userInfo">{{userInfo.nickname}}
						</image>
					</view>
					<view class="tui-explain">{{userInfo.type_name}}</view>
					<view class="tui-explain">推荐码：{{userInfo.mobile}}</view>
				</view>
			</view>
		</view>
		<view class="tui-content-box">
			<view class="tui-box">
				<tui-list-view>
					<tui-list-cell @click="openPage('../set/set')" :arrow="true" padding="40rpx 30rpx">
						<view class="tui-item-box">
							<image src="../../static/images/icon/setting.png" mode="widthFix"></image>
							<text class="tui-list-cell_name">设置</text>
						</view>
					</tui-list-cell>
					<tui-list-cell @click="openPage('../doc/doc')" :arrow="true" padding="40rpx 30rpx">
						<view class="tui-item-box">
							<image src="../../static/images/icon/H.png" mode="widthFix"></image>
							<text class="tui-list-cell_name">帮助中心</text>
						</view>
					</tui-list-cell>
					<tui-list-cell @click="openPage('./share')" :arrow="true"  padding="40rpx 30rpx">
						<view class="tui-item-box">
							<image src="../../static/images/icon/qrcode.png" mode="widthFix"></image>
							<text class="tui-list-cell_name">我的二维码</text>
						</view>
					</tui-list-cell>
					<tui-list-cell @click="openPage('../feedback/feedback')" :arrow="true"  padding="40rpx 30rpx">
						<view class="tui-item-box">
							<image src="../../static/images/icon/msg.png" mode="widthFix"></image>
							<text class="tui-list-cell_name">问题反馈</text>
						</view>
					</tui-list-cell>
					
				</tui-list-view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		onLoad: function(options) {
			let obj = {};
			// #ifdef MP-WEIXIN
			obj = wx.getMenuButtonBoundingClientRect();
			// #endif
			// #ifdef MP-BAIDU
			obj = swan.getMenuButtonBoundingClientRect();
			// #endif
			// #ifdef MP-ALIPAY
			my.hideAddToDesktopMenu();
			// #endif
			uni.getSystemInfo({
				success: (res) => {
					this.width = obj.left || res.windowWidth;
					this.height = obj.top ? (obj.top + obj.height + 8) : (res.statusBarHeight + 44);
					this.top = obj.top ? (obj.top + (obj.height - 32) / 2) : (res.statusBarHeight + 6);
					this.scrollH = res.windowWidth * 0.6
				}
			})
		},
		onShow: function() {
			this.tui.isLogin();
			this.getBase();
			this.getUserInfo();
		},
		data() {
			return {
				loadding: false,
				top: 0, //标题图标距离顶部距离
				opcity: 0,
				scrollTop: 0.5,
				base: {},
				menus: [],
				userInfo: {
					username: '',
					nick_name: '点击登录',
					avatar: '',
					leve_cn: '',
					vip_img: '/static/images/mall/my/icon_vip_3x.png'
				},
				productList: [],
				pullUpOn: true,
				usercenter_order_menus: []
			}
		},
		methods: {
			openPage: function(page) {
				uni.navigateTo({
					url: page
				})
			},
			getBase: function() {
				uni.showLoading({})
				this.tui.get('user/login/getsetting').then(res => {
					if (res.code == 1) {
						this.base = res.data.base;
						this.menus = res.data.menus;
					} else {
						this.tui.toast(res.msg);
					}
					uni.hideLoading()
				})
			},
			initNavigation(e) {
				this.opcity = e.opcity;
				this.top = e.top;
			},
			opcityChange(e) {
				this.opcity = e.opcity;
			},
			getUserInfo: function() {
				let it = this;
				this.tui.request('user/api/getuser', 'GET').then(function(res) {
					// console.log(res);
					if (res.code == 1) {
						it.userInfo = res.data;
					}
				})
			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		onPullDownRefresh() {
			this.getUserInfo();
			setTimeout(() => {
				uni.stopPullDownRefresh()
			}, 200)
		},
		onReachBottom: function() {
			if (!this.pullUpOn) return;
			this.loadding = true;
			if (this.pageIndex == 4) {
				this.loadding = false;
				this.pullUpOn = false
			} else {
				let loadData = JSON.parse(JSON.stringify(this.productList));
				loadData = loadData.splice(0, 10)
				if (this.pageIndex == 1) {
					loadData = loadData.reverse();
				}
				this.productList = this.productList.concat(loadData);
				this.pageIndex = this.pageIndex + 1;
				this.loadding = false
			}
		}
	}
</script>

<style>
	.tui-header-box {
		width: 100%;
		padding: 0 30rpx 0 20rpx;
		box-sizing: border-box;
		position: fixed;
		top: 0;
		left: 0;
		display: block;
		height: 32px;
		transform: translateZ(0);
		z-index: 9999;
		text-align: center;
		color: #FFFFFF;
	}

	/* #ifndef MP */
	.tui-header-icon {
		min-width: 60rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	/* #endif */
	/* #ifdef MP */
	.tui-set-box {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	/* #endif */
	.tui-icon-box {
		position: relative;
	}

	.tui-icon-setup {
		margin-left: 8rpx;
	}

	.tui-badge {
		position: absolute;
		font-size: 24rpx;
		height: 32rpx;
		min-width: 20rpx;
		padding: 0 6rpx;
		border-radius: 40rpx;
		right: 10rpx;
		top: -5rpx;
		transform: scale(0.8) translateX(60%);
		transform-origin: center center;
		display: flex;
		align-items: center;
		justify-content: center;
		z-index: 10;
	}

	.tui-badge-red {
		background: #F74D54;
		color: #fff;
	}

	.tui-badge-white {
		background: #fff;
		color: #F74D54;
	}

	.tui-badge-dot {
		position: absolute;
		height: 12rpx;
		width: 12rpx;
		border-radius: 50%;
		right: -12rpx;
		top: 0;
		background: #F74D54;
	}

	.tui-mybg-box {
		width: 100%;
		/* height: 464rpx; */
		position: relative;
	}

	.tui-my-bg {
		width: 100%;
		height: 464rpx;
		display: block;
	}

	.tui-header-center {
		position: absolute;
		width: 100%;
		height: 128rpx;
		left: 0;
		top: 120rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
	}

	.tui-avatar {
		flex-shrink: 0;
		width: 128rpx;
		height: 128rpx;
		display: block;
		border-radius: 100rpx;
	}

	.tui-info {
		width: 60%;
		padding-left: 30rpx;

	}

	.tui-nickname {
		font-size: 30rpx;
		font-weight: 500;
		color: #fff;
		display: flex;
		align-items: center;
	}

	.tui-img-vip {
		width: 56rpx;
		height: 24rpx;
		margin-left: 18rpx;
	}

	.tui-explain {
		width: 80%;
		font-size: 24rpx;
		font-weight: 400;
		color: #fff;
		opacity: 0.75;
		padding-top: 8rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.tui-btn-edit {
		flex-shrink: 0;
		padding-right: 22rpx;
	}

	.tui-header-btm {
		width: 100%;
		padding: 0 30rpx;
		box-sizing: border-box;
		position: absolute;
		left: 0;
		top: 280rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		color: #fff;
	}

	.tui-btm-item {
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.tui-btm-num {
		font-size: 32rpx;
		font-weight: 600;
		position: relative;
	}

	.tui-btm-text {
		font-size: 24rpx;
		opacity: 0.85;
		padding-top: 4rpx;
	}

	.tui-content-box {
		width: 100%;
		padding: 0 30rpx;
		box-sizing: border-box;
		position: relative;
		z-index: 10;
		margin-top: 10px;
	}

	.tui-box {
		width: 100%;
		background: #fff;
		box-shadow: 0 3rpx 20rpx rgba(183, 183, 183, 0.1);
		border-radius: 10rpx;
		overflow: hidden;
	}

	.tui-order-box {
		height: 208rpx;
	}

	.tui-cell-header {
		width: 100%;
		height: 74rpx;
		padding: 0 26rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.tui-cell-title {
		font-size: 30rpx;
		line-height: 30rpx;
		font-weight: 600;
		color: #333;
	}

	.tui-cell-sub {
		font-size: 26rpx;
		font-weight: 400;
		color: #999;
		padding-right: 28rpx;
	}

	.tui-order-list {
		width: 100%;
		height: 134rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: left;

	}

	.tui-order-item {
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.tui-order-text,
	.tui-tool-text {
		font-size: 26rpx;
		font-weight: 400;
		color: #666;
		padding-top: 4rpx;
	}

	.tui-tool-text {
		font-size: 24rpx;
	}

	.tui-order-icon {
		width: 56rpx;
		height: 56rpx;
		display: block;
	}

	.tui-assets-box {
		height: 178rpx;
		margin-top: 20rpx;
	}

	.tui-assets-list {
		height: 84rpx;
	}

	.tui-assets-num {
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
		position: relative;
	}

	.tui-assets-text {
		font-size: 24rpx;
		font-weight: 400;
		color: #666;
		padding-top: 6rpx;
	}

	.tui-tool-box {
		margin-top: 20rpx;
	}

	.tui-flex-wrap {
		flex-wrap: wrap;
		height: auto;
		padding-bottom: 30rpx;
	}

	.tui-tool-item {
		width: 25%;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		padding-top: 30rpx;
	}

	.tui-tool-icon {
		width: 64rpx;
		height: 64rpx;
		display: block;
	}

	.tui-badge-icon {
		width: 66rpx;
		height: 30rpx;
		position: absolute;
		right: 0;
		transform: translateX(88%);
		top: -15rpx;
	}
	.tui-item-box {
		width: 100%;
		display: flex;
		align-items: center;
		
	}
	.tui-item-box image{
		width: 22px;
		margin-right: 15px;
	}
</style>
